package io.geely.push;

import org.springframework.web.client.RestTemplate;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

public class RestTemplateTest {
	public static void main(String[] args) {
		RestTemplate restT = new RestTemplate();
		// 通过Jackson JSON processing library直接将返回值绑定到对象
		// Quote quote =
		// restT.getForObject("http://gturnquist-quoters.cfapps.io/api/random",
		// Quote.class);
		// String quoteString =
		// restT.getForObject("http://127.0.0.1:8089/api/push/list", String.class);
		JSONObject json = restT.getForEntity("http://127.0.0.1:8089/api/push/list", JSONObject.class).getBody();
		System.out.println(json.toJSONString());

		JSONArray jsonArray = json.getJSONArray("list");

		System.out.println(jsonArray);
		System.out.println(jsonArray.get(0));

		System.out.println(jsonArray.get(1));

		// = restTemplate.getForEntity(url, JSONObject.class).getBody();
		// System.out.println(quoteString);
	}
}